<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<button onclick="pi()">计算pi的值</button>
		<button onclick="sum()">计算9+99+999...</button>
		<script type="text/javascript">
		function pi(){
			for(var i=1,j=0,sum=0;i<100000;i+=2,j++){
				if(j%2==1){
					sum-=1/i;
				}else{
					sum+=1/i;
				}
			}
			console.log(sum*4);
		}
		
		function sum(){
			for(var i=0,str="",sum=0;i<10;i++){
			str+="9";
			sum+="+"+str;			
			}
				console.log(eval(sum));
			}
		
		</script>
	</body>
</html>
